﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ArticleList.aspx.cs" Inherits="School.SystemManage.WebPages.ArticlePage.ArticleList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <link href="../../css/right.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .td_title{ text-align:left;}
    </style>
    <script type="text/javascript">
        function CheckAll(checkBoxAll,isInTable) {
            var dataTable = document.getElementById("DataList");
            var checkBoxes = dataTable.getElementsByTagName("INPUT");
            var startIndex = 0;
            if (isInTable) {
                startIndex = 1;
            }
            for (var i = startIndex; i < checkBoxes.length; i++) {
                checkBoxes[i].checked = checkBoxAll.checked;
            }
        }

        function HasCheckedRow() {
            var dataTable = document.getElementById("DataList");
            var checkBoxes = dataTable.getElementsByTagName("INPUT");
            for (var i = 1; i < checkBoxes.length; i++) {
                if (checkBoxes[i].checked)
                    return confirm("确定要删除吗？");
            }
            alert("选择要删除的项");
            return false;
        }

        function HasSelectedRow() {
            var dataTable = document.getElementById("DataList");
            var checkBoxes = dataTable.getElementsByTagName("INPUT");
            for (var i = 1; i < checkBoxes.length; i++) {
                if (checkBoxes[i].checked)
                    return true;
            }
            alert("选择要审核的项");
            return false;
        }

        function OpenPreview(articleID) {
            window.open('ArticlePreview.aspx?aid=' + articleID, '', 'toolbar=no,scrollbars=yes,resizable=yes');
        }

        function ShowCheckPanel(parent) {
            var panel = document.getElementById("CheckPanel");
            panel.style.display = "block";
            //panel.style.left = parent.offsetLeft - panel.offsetWidth + parent.offsetWidth + "px";
            panel.style.left = document.body.clientWidth - 20 - panel.offsetWidth + "px";
            panel.style.top = "30px";
            //alert(panel.style.left);
        }

        function CloseCheckPanel(e) {
            var panela = document.getElementById("CheckPanel");
            panela.style.display = "none";
            stopBubble(e);
        }

        function stopBubble(e) {
            if (e && e.stopPropagation)
                e.stopPropagation();
            else
                window.event.cancelBubble = true;
        }

        function ShowRemarkInfo(obj) {
            var remarkPanel = obj.parentNode.lastChild;
            //alert(remarkPanel);
            remarkPanel.style.display = "block";
            //alert(remarkPanel.offsetWidth);
            remarkPanel.style.left = event.clientX - remarkPanel.offsetWidth;
        }

        function CloseRemarkPanel(obj) {
            var remarkPanel = obj.parentNode.parentNode.parentNode.lastChild;
            //alert(obj.parentNode);
            remarkPanel.style.display = "none";
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="container">
        <div class="title_bg">
            <div class="floatLeft title_text_div"><%=menu%> > <%=subMenu%></div> 
            <ul class="floatRight">
                <li><input id="chk_Total" type="checkbox" class="floatLeft" onclick="CheckAll(this,false);" /><span class="checkAll floatLeft">全选</span><div class="clear"></div></li>
                <li class="add" id="btnAddItem" runat="server"><a href="../../WebPages/ArticlePage/ArticleEdit.aspx?action=add&category=<%=categoryStr %>">添加</a></li>
                <li class="delete" id="btnDelItem" runat="server">
                    <asp:LinkButton ID="lbtnDelete" runat="server" 
                        OnClientClick="return HasCheckedRow();" onclick="lbtnDelete_Click" >删除</asp:LinkButton></li>
                <li class="articleCheck" onclick="ShowCheckPanel(this);" runat="server" id="btnCheckItem">审核
                    <div style=" position:absolute; display:none; padding-left:20px;" id="CheckPanel">
                        <asp:RadioButtonList ID="rbtnCheck" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Value="1" Selected="True">通过</asp:ListItem>
                            <asp:ListItem Value="2">未通过</asp:ListItem>
                        </asp:RadioButtonList>
                        <div>
                            原因：
                            <asp:TextBox ID="txbRemart" runat="server" TextMode="MultiLine" Height="50"></asp:TextBox>
                        </div>
                        <div style="text-align:center;">
                            <asp:Button ID="CheckSubmit" runat="server" Text="确认" 
                                onclick="CheckSubmit_Click" OnClientClick="return HasSelectedRow();" />
                            <input id="Button1" type="button" value="关闭" onclick=" CloseCheckPanel(event);" />
                        </div>
                    </div>
                </li>
            </ul>
            <div class="clear"></div>
        </div>
        <div>
            <asp:Repeater ID="rep_Article" runat="server" 
                onitemdatabound="rep_Article_ItemDataBound">
                <HeaderTemplate>
                    <table cellspacing="0" id="DataList" class="dataTable">
                        <tr>
                            <th style=" width:3%"><input id="chk_All" type="checkbox" onclick="CheckAll(this,true);" /></th>
                            <th style=" width:7%">类别</th>
                            <th style=" width:28%">标题</th>
                            <th style=" width:7%">首页新闻</th>
                            <th style=" width:8%">添加时间</th>
                            <th style=" width:8%">发布人</th>
                            <th style=" width:7%">是否审批</th>
                            <th style=" width:8%">审批人</th>
                            <th style=" width:8%">审批备注</th>
                            <th style=" width:8%">是否启用</th>
                            <th style=" width:8%">基本操作</th>
                        </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td><asp:CheckBox ID="cbChecked" runat="server"/></td>
                        <td><%=subMenu %></td>
                        <td class="td_title"><asp:HiddenField ID="hfAid" runat="server" Value='<%#Eval("ArticleID") %>' /> <%#Eval("Title")%></td>
                        <td><%#(bool)Eval("IsMainNews") == true ? "是" : "否"%></td>
                        <td><%#Eval("UpdateTime")%></td>
                        <td><%#Eval("UserName") %></td>
                        <td><%#GetCheckedStatue((byte)Eval("IsChecked"))%></td>
                        <td><%#Eval("CheckedUserName")%></td>
                        <td><span onclick="ShowRemarkInfo(this);" style="cursor:pointer;">查看</span>
                            <div class="remarkInfo">
                                <div class="remarkContent">
                                    <%#Eval("Remarks")%>
                                </div>                               
                                <div><input id="Button1" type="button" value="关闭" onclick="CloseRemarkPanel(this);" /></div>
                            </div>
                        </td>
                        <td><%#(bool)Eval("IsEnabled") == true ? "是" : "否"%></td>
                        <td>
                            <%--<a href='ArticleEdit.aspx?action=edit&category=<%=categoryStr %>&aid=<%#Eval("ArticleID") %>' id="editButton1" runat="server">编辑</a>--%>
                            <asp:HyperLink ID="editButton" runat="server">编辑</asp:HyperLink>
                            <a class="preview" onclick="OpenPreview('<%#Eval("ArticleID")%>');">预览</a>
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
        </div>
        <div class="red">
            <asp:Label ID="msg" runat="server" Text=""></asp:Label>
        </div>
    </div>
    </form>
</body>
</html>
